package com.dkm.rocketmq;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 消息生产者
 * @author 狄凯明
 *
 */
@Component
public class Producer {

	//注入rocketMQ的模板
	@Autowired
	private RocketMQTemplate rocketMQTemplate;
	
	/**
	 * 发送消息
	 * @param topic 主题
	 * @param msg 消息内容
	 */
	public void sendMsg(String topic,String msg) {
		this.rocketMQTemplate.convertAndSend(topic, msg);
	}
}
